<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>时间</title>
    <script type="text/javascript" language="JavaScript">
        
          self.setInterval("time()",1000)//每一秒弹出
        function time() {
            var  d=new Date();
            var weekday = new Array(7)
            weekday[0] = "星期天"
            weekday[1] = "星期一"
            weekday[2] = "星期二"
            weekday[3] = "星期三"
            weekday[4] = "星期四"
            weekday[5] = "星期五"
            weekday[6] = "星期六"

            if(d.getHours()>=0&&d.getHours()<=12){
               var ii="am";
            }
            else{
                ii="pm"
            }
            document.getElementById("time1").innerText=d.getFullYear()+"年"+
                d.getMonth()+"月"+d.getDate()+"日"+ii+" "+d.getHours()+"时"+d.getMinutes()+"分"+d.getSeconds()+"秒"+weekday[d.getDay()];
        }
        //innertext 返回标签内的文本值，不包含html标签
    </script>
</head>
<body>
          <span id="time1"></span>
</body>
</html>